﻿<template>
  <a-modal
    title="编辑短信发送记录信息"
    width="40%"
    :visible="visible"
    :confirmLoading="loading"
    @ok="handleSubmit"
    @cancel="()=>{this.visible=false}"
  >
    <a-spin :spinning="loading">
      <a-form-model ref="form" :model="entity" :rules="rules" v-bind="layout">
        <a-form-model-item label="排序" prop="Sort">
          <a-input v-model="entity.Sort" autocomplete="off" placeholder="越小越靠前"  />
        </a-form-model-item>
        <a-form-model-item label="接收人身份" prop="R_Identity">
          <a-input v-model="entity.R_Identity" autocomplete="off" placeholder="接收人身份-用于后期区分表查询"  />
        </a-form-model-item>
        <a-form-model-item label="目标手机号码" prop="R_PhoneNumbers">
          <a-input v-model="entity.R_PhoneNumbers" autocomplete="off" placeholder="接收短信的手机号码"  />
        </a-form-model-item>
        <a-form-model-item label="短信模板变量值" prop="R_TemplateParam">
          <a-input v-model="entity.R_TemplateParam" autocomplete="off" placeholder="短信模板变量对应的实际值，JSON格式。"  />
        </a-form-model-item>
        <a-form-model-item label="请求状态码" prop="R_Code">
          <a-input v-model="entity.R_Code" autocomplete="off" placeholder="请求状态码"  />
        </a-form-model-item>
        <a-form-model-item label="状态码描述" prop="R_Message">
          <a-input v-model="entity.R_Message" autocomplete="off" placeholder="状态码的描述"  />
        </a-form-model-item>
        <a-form-model-item label="发送回执ID" prop="R_BizId">
          <a-input v-model="entity.R_BizId" autocomplete="off" placeholder="发送回执ID-根据ID在接口QuerySendDetails中查询具体的发送状态详情"  />
        </a-form-model-item>
        <a-form-model-item label="自定义编码" prop="Code">
          <a-input v-model="entity.Code" autocomplete="off" placeholder="自定义编码"  />
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
export default {
  props: {
    parentObj: Object
  },
  data() {
    return {
      layout: {
        labelCol: { span: 5 },
        wrapperCol: { span: 18 }
      },
      visible: false,
      loading: false,
      entity: {},
      rules: {},
      title: ''
    }
  },
  methods: {
    init () {
      this.visible = true
      this.entity = {}
      this.$nextTick(() => {
        this.$refs['form'].clearValidate()
      })
    },
    openForm (id, title) {
      this.init()

      if (id) {
        this.loading = true
        this.$http.post('/Base_Manage/Base_SMSRecord/GetTheData', { id: id }).then(resJson => {
          this.loading = false

          this.entity = resJson.Data
        })
      }
    },
    handleSubmit () {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        this.loading = true
        this.$http.post('/Base_Manage/Base_SMSRecord/SaveData', this.entity).then(resJson => {
          this.loading = false

          if (resJson.Success) {
            this.$message.success('操作成功!')
            this.visible = false

            this.parentObj.getDataList()
          } else {
            this.$message.error(resJson.Msg)
          }
        })
      })
    }
  }
}
</script>
